﻿<!--/************************************************************************************  
' Copyright (C) 2009 Anthony Bouch (http://www.58bits.com) under the terms of the
' Microsoft Public License (Ms-PL http://www.codeplex.com/precode/license)
'***********************************************************************************/-->
    <ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:FiftyEightBits.PreCode"
    >
    <Style TargetType="{x:Type local:ToolBarButton}">
        <Setter Property="Foreground" Value="{DynamicResource FontForecolor}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="FontSize" Value="{DynamicResource {x:Static SystemFonts.MenuFontSizeKey}}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ToolBarButton}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="Timeline1">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="GelBackgroundOver" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1500000" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="Timeline2">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="GelBackgroundOver" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1500000" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <LinearGradientBrush x:Key="MouseOverFill" StartPoint="0,0" EndPoint="0,1">
                            <!--<GradientStop Color="#77CCCCCC" Offset="0"/>
                                <GradientStop Color="#22AAAAAA" Offset="1.0"/>-->
                            <GradientStop Color="#BB888888" Offset="0"/>
                            <GradientStop Color="#99777777" Offset="0.2"/>
                            <GradientStop Color="#55666666" Offset="0.6"/>
                            <GradientStop Color="#44222222" Offset="1.0"/>
                        </LinearGradientBrush>

                        <LinearGradientBrush x:Key="MouseDownFill" StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#22CCCCCC" Offset="0"/>
                            <GradientStop Color="#00AAAAAA" Offset="1.0"/>
                        </LinearGradientBrush>
                    </ControlTemplate.Resources>

                    <Border Height="Auto" Width="{TemplateBinding Width}" Margin="{TemplateBinding Margin}">
                        <Grid Height="Auto" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0">
                            <Grid x:Name="GelBackgroundOver" Opacity="0" Height="Auto" Width="Auto" >
                                <Rectangle SnapsToDevicePixels="True" x:Name="BackGroundEffect1" Margin="0" RadiusX="1" RadiusY="1" Stroke="#FF222222" StrokeThickness="0.5" />
                                <Rectangle SnapsToDevicePixels="True" x:Name="BackGroundEffect2" Margin="1" RadiusX="1" RadiusY="1" Stroke="#FFCCCCCC" StrokeThickness="0.5" Fill="{StaticResource MouseOverFill}" />
                            </Grid>
                            <StackPanel Margin="4,0,4,0" Orientation="Horizontal"  VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                                <Image HorizontalAlignment="Center" Width="{TemplateBinding ImageWidth}" Height="{TemplateBinding ImageHeight}" SnapsToDevicePixels="True" VerticalAlignment="Center" Source="{TemplateBinding Source}" />
                                <Label Padding="{TemplateBinding Padding}" HorizontalAlignment="Center" Margin="0,0,0,2" HorizontalContentAlignment="Center" Width="Auto" Foreground="{TemplateBinding Foreground}" FontSize="{DynamicResource {x:Static SystemFonts.MenuFontSizeKey}}" Content="{TemplateBinding Content}" />
                            </StackPanel>
                        </Grid>
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource Timeline1}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource Timeline2}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="BackGroundEffect2" Property="Fill" Value="{StaticResource MouseDownFill}"></Setter>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{DynamicResource DisabledFontForecolor}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>

            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:ToolBarToggle}">
        <Setter Property="Foreground" Value="{DynamicResource FontForecolor}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="FontSize" Value="{DynamicResource {x:Static SystemFonts.MenuFontSizeKey}}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ToolBarToggle}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="ImageTimeline1">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ButtonImage" Storyboard.TargetProperty="(Image.RenderTransform).(RotateTransform.Angle)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1500000" Value="90"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="ImageTimeline2">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ButtonImage" Storyboard.TargetProperty="(Image.RenderTransform).(RotateTransform.Angle)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1500000" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>

                        <!--<Storyboard x:Key="ImageTimeline1">
              <DoubleAnimation From="0" To="90" Duration="00:00:00:50" Storyboard.TargetName="ButtonImage" Storyboard.TargetProperty="(Image.RenderTransform).(RotateTransform.Angle)" />
            </Storyboard>
            <Storyboard x:Key="ImgaeTimeline2">
              <DoubleAnimation From="90" To="0" Duration="00:00:00:50" Storyboard.TargetName="ButtonImage" Storyboard.TargetProperty="(Image.RenderTransform).(RotateTransform.Angle)" />              
            </Storyboard>-->
                        <LinearGradientBrush x:Key="IsMouseOverFill" StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#00555555" Offset="0"/>
                            <GradientStop Color="#22555555" Offset="0.4"/>
                            <GradientStop Color="#22CCCCCC" Offset="1.0"/>
                        </LinearGradientBrush>

                        <LinearGradientBrush x:Key="IsNotCheckedFill" StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#22BBBBBB" Offset="0"/>
                            <GradientStop Color="#00555555" Offset="0.4"/>
                            <GradientStop Color="#00555555" Offset="1.0"/>
                        </LinearGradientBrush>

                        <LinearGradientBrush x:Key="IsCheckedFill" StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#00555555" Offset="0"/>
                            <GradientStop Color="#00555555" Offset="0.4"/>
                            <GradientStop Color="#22BBBBBB" Offset="1.0"/>
                        </LinearGradientBrush>
                    </ControlTemplate.Resources>

                    <Grid Margin="0" Height="Auto" Width="Auto">
                        <Grid x:Name="GelBackgroundOver" Opacity="1" Margin="0" Height="Auto" Width="Auto" >
                            <Border SnapsToDevicePixels="True" x:Name="BackGroundEffect1" Margin="2,3,2,2" CornerRadius="2" BorderThickness="0.5,0.5,0,0" BorderBrush="#FF999999" />
                            <Border SnapsToDevicePixels="True" x:Name="BackGroundEffect2" Background="{StaticResource IsNotCheckedFill}" Margin="2,3,2,2" CornerRadius="2" BorderThickness="0,0,0.5,0.5" BorderBrush="#FF444444" />
                        </Grid>
                        <Border Padding="4,0,5,0" Margin="0">
                            <StackPanel Orientation="Horizontal">
                                <Image x:Name="ButtonImage" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5" Height="{TemplateBinding ImageHeight}" Width="{TemplateBinding ImageWidth}" Source="{TemplateBinding Source}">
                                    <Image.RenderTransform>
                                        <RotateTransform Angle="0" />
                                    </Image.RenderTransform>
                                </Image>
                                <Label Foreground="{TemplateBinding Foreground}" VerticalAlignment="Center" FontSize="{DynamicResource {x:Static SystemFonts.MenuFontSizeKey}}" Content="{TemplateBinding Text}" />
                            </StackPanel>
                        </Border>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="BackGroundEffect2" Property="Background" Value="{StaticResource IsMouseOverFill}"></Setter>
                        </Trigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsChecked" Value="True" />
                                <Condition Property="IsMouseOver" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="BackGroundEffect1" Property="BorderBrush" Value="#FF444444"></Setter>
                            <Setter TargetName="BackGroundEffect2" Property="BorderBrush" Value="#FF999999"></Setter>
                            <Setter TargetName="BackGroundEffect2" Property="Background" Value="{StaticResource IsCheckedFill}"></Setter>
                        </MultiTrigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsChecked" Value="True" />
                                <Condition Property="IsMouseOver" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="BackGroundEffect1" Property="BorderBrush" Value="#FF444444"></Setter>
                            <Setter TargetName="BackGroundEffect2" Property="BorderBrush" Value="#FF999999"></Setter>
                            <Setter TargetName="BackGroundEffect2" Property="Background" Value="{StaticResource IsMouseOverFill}"></Setter>
                        </MultiTrigger>

                        <Trigger Property="IsChecked" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource ImageTimeline1}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource ImageTimeline2}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{DynamicResource DisabledFontForecolor}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>

            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
